<template>
  <view>
    <view>
      列表ds
    </view>
       <view>
      列表ds
    </view>
  </view>
</template>

<script>
import pub from '@/utils/pub.js'
export default {
  name: 'shoppingCart',
  props: {
    selectedGoodsList: Array,
    default: [],
    visible: {
      type: Boolean,
      default: true,
    },
  },
  onLoad(option) {
    console.log(option)
    this.order = option.order
    this.news = option.news
    this.photo = option.photo
  },
  data() {
    return {
      order: '',
      news: '',
      photo: '',
      totalAmount: 0,
    }
  },
  mounted() {
    // pub.$on('updateGoodsData',()=>{
    //   const val = this.selectedGoodsList.reduce((prev,cur)=>{
    //     console.log(prev,cur)
    //     prev+Number(cur.taxAmount)
    //   },0)
    //   console.log(val)
    //   this.totalAmount = val.toFixed(2)
    // })
  },
  computed: {
    getAmount() {
      const val = this.selectedGoodsList.reduce((prev, cur) => prev + Number(cur.taxPrice * cur.goodsCount), 0)

      return val.toFixed(2)
    },
  },
  methods: {
    showCartPop() {
      this.$emit('showCartPop')
    },
    jump(type) {
      //显示购物车详情

      if (!this.selectedGoodsList.length) return uni.showToast({ title: '请先选择商品', icon: 'none' })
      if (type === 'shoppingCart') this.back = 1
      uni.navigateTo({ url: `/pageShopping/${type}/index?order=${this.order}&&news=${this.news}&photo=${this.photo}&back=${this.back}` })
    },
  },
}
</script>

<style lang="scss" scoped>
.shoppingBox {
  background-image: linear-gradient(to bottom, #ffffff, #ffffff, #fff9d7);
  height: 100rpx;
  width: 100%;
  position: fixed;
  align-items: center;
  bottom: 0;
  z-index: 98;
  color: #ffffff;
  .img {
    width: 100rpx;

    margin-left: 30rpx;
  }
  .settlement {
    background: linear-gradient(to right, #ffb300, #ff8f00);
    color: #ffffff;
    width: 200rpx;
    position: absolute;
    right: 0;
    height: 80%;
    border-radius: 50rpx;
    font-size: 35rpx;
  }
  .price {
    color: red;
    width: 300rpx;
    display: flex;
    align-items: center;
    font-size: 48rpx;
    padding-left: 30rpx;
    &:before {
      content: '￥';
      font-size: 26rpx;
    }
  }
}
.redDot {
  min-width: 40rpx;
  height: 40rpx;
  background: red;
  border-radius: 40rpx;
  border: #ffffff 2px solid;
  position: absolute;
  left: 120rpx;
  top: 0;
}
</style>
